package com.guoguo.sincemusic.ui

import android.annotation.SuppressLint
import android.content.Intent
import com.guoguo.sincemusic.databinding.ActivitySplashBinding
import com.guoguo.sincemusic.logic.dao.Storage
import com.guoguo.sincemusic.ui.common.BaseActivity
import java.util.*
import kotlin.concurrent.schedule

@SuppressLint("CustomSplashScreen")
class SplashActivity : BaseActivity() {
    private lateinit var binding: ActivitySplashBinding
    override fun initBinding() {
        super.initBinding()
        // 置空window背景图
        window.setBackgroundDrawable(null)
        binding = ActivitySplashBinding.inflate(layoutInflater)
        setContentView(binding.root)
    }

    override fun initView() {
        super.initView()
        val isLogin: Boolean = Storage.isLogin()
        Timer().schedule(2000) {
            val intent = Intent(
                this@SplashActivity,
                if (isLogin) MainActivity::class.java
                else StepperActivity::class.java
            )
            startActivity(intent)
            finish()
        }
    }
}